
var InterValObj; //timer变量，控制时间
var curCount = 60;//当前剩余秒数
var yanzma='';

$(function () {
	$("#yanzma").on('keyup',function(e) {
		yanzma = $(this).val();
	});

	$('#getCheckword').click(function () {
		if (yanzma){
			$("#getCheckword").attr("disabled", "true");
			$("#getCheckword").attr("style","color:#ccc;");
			$("#getCheckword").html(curCount + "秒后重试");
			InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
		}else{

		}

	});
});

function SetRemainTime() {
	if (curCount == 0) {
		window.clearInterval(InterValObj);//停止计时器
		$("#getCheckword").removeAttr("disabled");//启用按钮
		$("#getCheckword").attr("style","color:#ff7300;");
		$("#getCheckword").html("获取验证码");
		curCount=60;
	}else {
		curCount--;
		$("#getCheckword").html(curCount + "秒后重试");
	}
}

function checkPhone(){

	var phone = $("#phone").val();
	/^(1)\d{10}$/
	if( phone.match(/^(1)\d{10}$/)){

		$("#getCheckcode").removeAttr("disabled");
		return true;
	}else{

		$("#getCheckcode").attr("disabled", "true");
		return false;
		$(".icon-close").show();

	}
}

function checkMima(){
	checkSubmit();
	var mima = $("#mima").val();
	if( mima.length != 0){

		return true;
	}else{
		return false;

	}
}

function checkMima2(){
	checkSubmit();
	var mima2 = $(".mima2").val();
	if( mima2.length > 6){

		return true;
	}else{
		return false;

	}
}

function checkYonghu(){
	checkSubmit();
	var yonghu = $("#yonghu").val();
	if( yonghu.length > 6){
		return true;
	}else{
		return false;

	}
}


function checkSubmit(){

	var phone = $("#phone").val();
	var yonghu = $("#yonghu").val();
	var mima2 = $(".mima2").val();

	if( yonghu.length > 4 && mima2.length > 4 ){
		$("#btn-submit").css("color","#fff");
		$("#btn-submit").attr("disabled",false);
	}else{
		$("#btn-submit").css("color","#ffc595");
		$("#btn-submit").attr("disabled",true);
	}

}

    
